--- /** * Single Post * * Demonstrates: * - getEmDashEntry for fetching a single entry * - getEntryTerms for taxonomy terms (NO db parameter!) * - PortableText component for rich content * - Proper image field access */ import { getEmDashEntry, getEntryTerms } from "emdash"; import { Image, PortableText } from "emdash/ui"; import Base from "../../layouts/Base.astro"; const { slug } = Astro.params; const { entry: post, error } = await getEmDashEntry("posts", slug!); if (error) { return new Response("Server error", { status: 500 }); } if (!post) { return Astro.redirect("/404"); } // Get taxonomy terms - NOTE: no db parameter! const categories = await getEntryTerms("posts", post.id, "categories"); const tags = await getEntryTerms("posts", post.id, "tags"); const formattedDate = post.data.published_at ? new Date(post.data.published_at).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", }) : null; ---

{post.data.title}

{/* IMPORTANT: Check .src, not just the field */} { post.data.featured_image?.src && (
{post.data.featured_image.alt
) }
{post.data.content && }
{ tags.length > 0 && ( ) }